{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" href="/public/lboyue/m/css/loading.css">
<script type="text/javascript" src="/public/lboyue/m/sitejs/book.js?v=20181123"></script>
<script type="text/javascript">

    $(document).ready(function () {


        $('.moreIco').click(function () {

            if($(this).hasClass('closeIco')){

                $('#header').removeClass('app_headerFixed2');
                $(this).removeClass('closeIco');
                $('.app_header_second').hide();
                $('.app_meskSection').hide();

            }else{

                $('#header').addClass('app_headerFixed2');
                $(this).addClass('closeIco');
                $('.app_header_second').show();
                $('.app_meskSection').show();
            }



        })

        $('body').on('click','.app_meskSection',function () {
            $('.app_header_second').hide();
            $('.app_meskSection').hide();
            $('#header').removeClass('app_headerFixed2');
            $('.moreIco').removeClass('closeIco');
        })
    })

</script>
{/block}
{block name="body"}

<div class="app_goBackToTop"></div>
<div class="app_meskSection"></div>

<div class="container">

    <div class="app_header_section2  app_scrollerHeader" id="header">
        <div class="app_header_detail2">
            <div class="app_header_back"></div>
            <div class="app_header_h1">
                消费记录                <a href="/bookshelf"> <i class="shujiaIco"></i></a>
                <i class="moreIco"></i>
            </div>
        </div>
		{include file="public/dropnav" /}
	</div>



    <div class="app_body">
    
	<div class="app_rechargeRecord">
        
		<div class="app_rechargeRecord_list">
            <ul>
            </ul>
        </div>

        <div class="app_noDataBlock">
            没有记录, 去其它页面看看吧
        </div>
        
    </div>
    {block name="include"}{include file="public:footer" /}{/block}
    </div>
</div>
	
{/block}
{block name="script"}
   <script type="text/javascript">

        var allowloadmore=true;
        var pageindex=1;
		var sBookstop=true, 
			sBookstopTime=null;
        var type={$type};
        function loadMore(object) {
			
            
			//注意：这里只是模拟滚动到底部加载更多数据，实际开发中是使用ajax异步请求操作;
			allowloadmore=false;
			$('.app_reload').fadeIn(300);
			$(".app_noData").hide();
			$.ajax({
				url: "/api/user/moneylog/",
				type: "GET",
				dataType: "json",
				data: {"page":pageindex,"type":type},
				success: function (re) {
					clearTimeout(sBookstopTime);
					var data=re.data;
					if(data<=0 && pageindex == 1){
						$('.app_noDataBlock').show();
						sBookstop = false;
						return false;
					}
					if (re.code == 1) {
						pageindex=pageindex+1;
						$(".app_noDataBlock").hide();
						var html="";
						for (var i=0;i<data.length;i++)
						{
							html+="<li >";
							
							html+="<div class=\"leftBlock\"><i><img src=\"/public/lboyue/m/images/yd_ico.png\"/></i></div>";
							
							
							html+="<div class=\"rightBlock\"><div class=\"lis\"><span class=\"left1\">"+data[i].title+"</span><span class=\"right1\">"+data[i].shubi+data[i].virtualname+"</span></div><div class=\"lis\"><span class=\"left2\"></span><span class=\"right2\">"+data[i].create_time+"</span></div></div></li>";
						}
						object.find('ul').append(html);
					} else {
						sBookstop = false;
						//$(".app_noDataBlock").show();
					}

				},
				error: function () {
					sBookstop = false;
					$(".app_noDataBlock").show();
				}
			});
           
        }

        $(document).ready(function () {
			/**
            $(window).scroll(function () {
                loadMore($('.app_rechargeRecord_list'));
            });

            document.addEventListener('touchstart',function () {
                loadMore($('.app_rechargeRecord_list'));
            },false);
            document.addEventListener('touchmove',function () {
                loadMore($('.app_rechargeRecord_list'));
            },false);
            document.addEventListener('touchend',function () {
                loadMore($('.app_rechargeRecord_list'));
            },false);
			**/
			loadMore($('.app_rechargeRecord_list'));
			$(window).scroll(function(){
				var nWinH =  document.documentElement.clientHeight;
				var nScrollTop = (document.body.scrollTop || document.documentElement.scrollTop) + nWinH;
				var nBodyScrollH = document.body.scrollHeight;
				if(sBookstop && nBodyScrollH - nScrollTop < 240){
					bookstoptime();
					loadMore($('.app_rechargeRecord_list'));
				}
			});
        })

		//防止重复请求数据
		function bookstoptime() {
			clearTimeout(sBookstopTime);
			sBookstop = false;
			sBookstopTime = setTimeout(function () {
				sBookstop = true;
			}, 3000);
		}
    </script>
{/block}


